package com.example.healthsystem.config;

import com.example.healthsystem.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.builders.WebSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.config.http.SessionCreationPolicy;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

//@Configuration
//@EnableWebSecurity
//@EnableGlobalMethodSecurity(prePostEnabled = true)
//public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
////    @Autowired
////    private MyAuthenticationProvider provider;// 自定义的AuthenticationProvider
//
//    @Autowired
//    UserServiceImpl userService;
//
//    @Autowired
//    MyAuthenticationEntryPoint myAuthenticationEntryPoint;
//
////    此处决定采用BCryptPasswordEncoder
////    @Bean
////    public PasswordEncoder myPasswordEncoder() {
////        return new MyPasswordEncoder();//自定义的加密工具
////    }
//    @Bean
//    public BCryptPasswordEncoder bCryptPasswordEncoder(){
//        return new BCryptPasswordEncoder();
//    }
//
//    @Override
//    public void configure(AuthenticationManagerBuilder auth) throws Exception {
////        auth.authenticationProvider(provider);
//        auth.userDetailsService(userService);
//    }
//
//    @Override
//    public void configure(WebSecurity web) throws Exception{
//        // --- 直接绕开所有filter ---
//        web.ignoring()
//                .antMatchers("/swagger-ui.html")
//                .antMatchers("/v2/**")
//                .antMatchers("/swagger-resources/**");
//    }
//
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//        http
//                .csrf().disable()
//                .cors().and()
//
//                .sessionManagement()
//                .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
//                .and()
//
//                .authorizeRequests()
////                .anyRequest().authenticated()
////                .antMatchers("/amdin/**").hasRole("admin")
////                .antMatchers("/user/**").hasAnyRole("student","teacher")
//                .anyRequest().permitAll()
////                .and()
////                .formLogin().loginProcessingUrl("/login")
//                // swagger
//
//                .and()
//                .addFilterBefore(new JWTLoginFilter("/login",authenticationManager()), UsernamePasswordAuthenticationFilter.class)
//                .addFilterBefore(new JwtFilter(),UsernamePasswordAuthenticationFilter.class)
//                //用户未认证时执行该操作
//                .exceptionHandling().authenticationEntryPoint(myAuthenticationEntryPoint);
//    }
//
//
//
//}
public class WebSecurityConfig{

}